/**
 * 获得租户功能是否开启
 */
export function getTenantEnable() {
  const VITE_TENANT_ENABLE = import.meta.env.VITE_APP_TENANT_ENABLE
  if (VITE_TENANT_ENABLE === 'true') {
    return true
  }
  if (VITE_TENANT_ENABLE === 'false') {
    return false
  }
  return VITE_TENANT_ENABLE || true
}

/**
 * 获得验证码功能是否开启
 */
export function getCaptchaEnable() {
  const VITE_CAPTCHA_ENABLE = import.meta.env.VITE_APP_CAPTCHA_ENABLE
  if (VITE_CAPTCHA_ENABLE === 'true') {
    return true
  }
  if (VITE_CAPTCHA_ENABLE === 'false') {
    return false
  }
  return VITE_CAPTCHA_ENABLE || true
}

// 首字母大小
export function titleCase(str) {
  return str.replace(/( |^)[a-z]/g, (L) => L.toUpperCase())
}

// -转驼峰
export function toCamelCase(str, upperCaseFirst) {
  str = (str || '').toLowerCase().replace(/-(.)/g, function (match, group1) {
    return group1.toUpperCase()
  })

  if (upperCaseFirst && str) {
    str = str.charAt(0).toUpperCase() + str.slice(1)
  }

  return str
}
